home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / ZICANCEL.CPP < prev    next >
C/C++ Source or Header  |  1993-08-09  |  5KB  |  186 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    zn.cpp
  5. //   Title:    Zinc Window Template
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains code for the class ZI_CANCEL.
  24. //
  25. //    The code in this module may be written in C++ or C.
  26. //
  27. //    This module is portable to:
  28. //        DOS 3.X+
  29. //        MS Windows 3.X+
  30. //        OS/2 2.X+
  31. //        OS/2 2.0 PM
  32. //
  33. //    The following compilers are supported:
  34. //        MSC 6.0A
  35. //        MSC/C++ 7.0
  36. //        Borland C++ 3.1 for DOS
  37. //        Borland C++ 1.0 for OS/2 2.X
  38. //
  39. //----------------------------------------------------------------------------
  40. #include <zi.hpp>
  41. #define USE_WIN_CANCEL
  42. #if OS_DOS
  43. #include <zid.hpp>
  44. #elif OS_WINDOWS
  45. #include <ziw.hpp>
  46. #else
  47. #include <zio.hpp>
  48. #endif
  49.  
  50.  
  51. //----------------------------------------------------------------------------
  52. //   Description:    Default constructor
  53. //    Parameters:
  54. //       Returns:    
  55. //----------------------------------------------------------------------------
  56. FN_M ZI_CANCEL::ZI_CANCEL()
  57. : ZN_WINDOW("WIN_CANCEL", ZN_LOAD_CENTER)
  58. {
  59.     ZI_CANCEL::Initialize(CL_INIT_CLASS);
  60.     Setup();
  61. }
  62.  
  63.  
  64. //----------------------------------------------------------------------------
  65. //   Description:    Destructor
  66. //    Parameters:
  67. //       Returns:    
  68. //----------------------------------------------------------------------------
  69. FN_M ZI_CANCEL::~ZI_CANCEL()
  70. {
  71.     ZI_CANCEL::Destroy(FALSE);
  72.     Terminate();
  73. }
  74.  
  75.  
  76. //----------------------------------------------------------------------------
  77. //   Description:    Destroy object. Free any resources used by object.
  78. //                          Normally called by destructor.
  79. //                        Should allow multiple calls from various classes.
  80. //                        A class should almost always re-init its variables when 
  81. //                        it is destroyed to prevent accidents.
  82. //    Parameters:    fDestroyAll        Destroy parents also?
  83. //                                            Default is TRUE.
  84. //       Returns:    TRUE if successful.
  85. //----------------------------------------------------------------------------
  86. BOOL FN_M ZI_CANCEL::Destroy(BOOL fDestroyAll)
  87. {
  88.     // Destroy object specific stuff
  89.     ZI_CANCEL::Initialize(CL_INIT_CLASS_VARS);
  90.     if (fDestroyAll)                            // Destroy parent.
  91.         ZI_CANCEL_PARENT::Destroy(fDestroyAll);
  92.     return TRUE;
  93. }
  94.  
  95.  
  96. //----------------------------------------------------------------------------
  97. //   Description:    Initialize object. 
  98. //                          Normally called by constructor.
  99. //                        Should allow multiple calls from various classes.
  100. //    Parameters:    sInit        Initialization code. May be one of the following:
  101. //                                        CL_INIT_CLASS            Reset class variables and
  102. //                                                                    and dynamic allocations for
  103. //                                                                    this class only.
  104. //                                        CL_INIT_CLASS_VARS    Reset class variables for
  105. //                                                                    this class only.
  106. //                                        CL_INIT_VARS            Reset class variables for
  107. //                                                                    this class only.
  108. //                                        CL_INIT_ALL                Initialize class and all 
  109. //                                                                    parent class, including
  110. //                                                                    dynamic memory allocation.
  111. //                                    Default is CL_INIT_ALL
  112. //       Returns:    TRUE if successful.
  113. //----------------------------------------------------------------------------
  114. BOOL FN_M ZI_CANCEL::Initialize(SHORT sInit)
  115. {
  116.     if (sInit == CL_INIT_VARS || sInit == CL_INIT_ALL)
  117.         ZI_CANCEL_PARENT::Initialize(sInit);
  118.  
  119.     sBitmap = 0;
  120.     return TRUE;
  121. }
  122.  
  123.  
  124. //----------------------------------------------------------------------------
  125. //   Description:    
  126. //    Parameters:    
  127. //       Returns:    Event code
  128. //----------------------------------------------------------------------------
  129. VOID FN_M ZI_CANCEL::NextBitmap(SHORT sNext)
  130. {
  131. static PCSZ apcsz[] =
  132.    {
  133.    "USA0",
  134.    "USA1",
  135.    "USA2",
  136.    "USA3",
  137.    "USA4",
  138.    "USA5",
  139.    "USA6",
  140.     "USA7",
  141.     NULL
  142.    };
  143.  
  144.     if (sNext >= 0)
  145.         sBitmap = MIN(sNext, (sizeof(apcsz)/sizeof(PCSZ)) - 2);
  146.  
  147.     LoadButtonBitmap(FID(BUTTON_CANCEL), apcsz[sBitmap]);
  148.     sBitmap++;
  149.     if (apcsz[sBitmap] == NULL)
  150.         sBitmap = 0;
  151.  
  152.     return ;
  153. }
  154.  
  155.  
  156. //----------------------------------------------------------------------------
  157. //   Description:    Event monitor function.
  158. //    Parameters:    msg        Event code
  159. //                        pv1            Data pointer 1
  160. //                        pv2            Data pointer 2
  161. //       Returns:    Event code
  162. //----------------------------------------------------------------------------
  163. ZN_MSG FN_M ZI_CANCEL::User(ZN_MSG msg, PVOID, PVOID)
  164. {
  165.     switch (msg)
  166.         {
  167.         case ZN_MSG_INIT:
  168.             return msg;
  169.  
  170.         case ZN_MSG_TERMINATE:
  171.             return msg;
  172.         }
  173.     if (IsError())                                // Error condition
  174.         return msg;
  175.     switch (msg)
  176.         {
  177.         case BUTTON_CANCEL:
  178.             SendMessage(ZiMainWindow(), ZI_MSG_ABORT, NULL, NULL);
  179.             break;
  180.         }
  181.     return msg;
  182. }
  183. //----------------------------------------------------------------------------
  184. //------------------------------- End of File --------------------------------
  185. //----------------------------------------------------------------------------
  186.